#!/bin/bash

count=0
for FileOrDir; do
	count=$(($count + 1))
done
step=$((100 / $count))
progess=0
(
	for FileOrDir; do
		echo "$progess"
		echo "# 归档 $FileOrDir ..."
		tar -cvf "$FileOrDir.tar" "$FileOrDir"
		progess=$(($progess + $step))
	done
	echo "# 归档完毕"
) | zenity --progress --title="文件归档" --text="归档中 ..." --percentage=0
if [ "$?" = 1 ]; then
	zenity --error --text="归档终止"
fi
